package com.dstation.controller;

import com.dstation.domain.SubscriptionPackageInfo;
import com.dstation.service.interf.ISubscriptionPackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author Eastward
 * @date 2022/5/8 - 21:31
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private ISubscriptionPackageService subscriptionPackageService;

    @GetMapping("/indexPage")
    public String indexPage() {
        return "admin/index";
    }

    @RequestMapping("/logout")
    public String logout(HttpSession session) {
        session.removeAttribute("adminInfo");
        return "admin/login";
    }

    @GetMapping("/queryAllSubscriptionPackages")
    public String queryAllSubscriptionPackages(ModelMap modelMap) {
        List<SubscriptionPackageInfo> list = subscriptionPackageService.findAllSubscriptionPackages();
        modelMap.put("subscriptionPackageList", list);
        return "admin/subscriptionPackage";
    }
}
